﻿Public Class Form1

    '数据库连接
    Private m_cnADONETConnection As New OleDb.OleDbConnection()
    Private m_dadataadapter As OleDb.OleDbDataAdapter
    Private m_cbcommandbuilder As OleDb.OleDbCommandBuilder
    Private m_dtcntacts As New DataTable
    Private m_rowposition As Integer = 0



    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        m_cnADONETConnection.Close()
        m_cnADONETConnection.Dispose()
    End Sub
    Private Sub showcurrentrecord()
        If m_dtcntacts.Rows.Count = 0 Then
            txtcontactname.text = ""
            txtstate.text = ""
            Exit Sub
        End If

        txtcontactname.text = m_dtcntacts.Rows(m_rowposition)("contactname").ToString()
        txtstate()
    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        m_cnADONETConnection.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\contacts.mdb"
        m_cnADONETConnection.Open()
        m_dadataadapter = New OleDb.OleDbDataAdapter("select * from contacts", m_cnADONETConnection)
        m_cbcommandbuilder = New OleDb.OleDbCommandBuilder(m_dadataadapter)
        m_dadataadapter.Fill(m_dtcntacts)




    End Sub
End Class
